home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / c / sozobon / sozlib15.zoo / sozdistr / include / xdlibs / filesys.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-07-09  |  19.9 KB  |  677 lines

  1. /* 
  2.  * @(#) filesys.h for SozobonX XdLibs
  3.  * 
  4.  * based on file.h/filesys.h from MiNT distrib
  5.  * see following note
  6.  */
  7.  
  8. /*
  9.  * NOTE: This file only works if sizeof(int) == 2!
  10.  * UNLESS: you have an ANSI compiler and use prototypes
  11.  *
  12.  * Copyright 1991,1992 Eric R. Smith. This file may be re-distributed
  13.  * as long as this notice remains intact.
  14.  */
  15.  
  16. #ifndef _filesys_h
  17. #define _filesys_h
  18.  
  19. #ifndef P_
  20. # ifdef __STDC__
  21. #  define P_(x) x
  22. # else
  23. #  define P_(x) ()
  24. # endif
  25. #endif
  26.  
  27. #ifdef _SHORTINT
  28. #define _wORD int
  29. #endif
  30.  
  31. #ifndef _wORD
  32. #ifdef __MSHORT__        /* 16 bit integers? */
  33. #define _wORD int
  34. #else
  35. #define _wORD short
  36. #endif
  37. #endif
  38.  
  39. #define TOS_NAMELEN 13
  40.  
  41. struct filesys;        /* forward declaration */
  42. struct devdrv;        /* ditto */
  43. struct timeout;        /* and ditto */
  44.  
  45. typedef struct f_cookie {
  46.     struct filesys *fs;    /* filesystem that knows about this cookie */
  47.     unsigned short    dev;        /* device info (e.g. Rwabs device number) */
  48.     unsigned short    aux;        /* extra data that the file system may want */
  49.     long    index;        /* this+dev uniquely identifies a file */
  50. } fcookie;
  51.  
  52.  
  53. typedef struct dtabuf {
  54.     short    index;        /* index into arrays in the PROC struct */
  55.     long    magic;
  56. #define SVALID    0x1234fedcL    /* magic for a valid search */
  57. #define EVALID    0x5678ba90L    /* magic for an exhausted search */
  58.  
  59.     char    dta_pat[TOS_NAMELEN+1];    /* pointer to pattern, if necessary */
  60.     char    dta_sattrib;    /* attributes being searched for */
  61. /* this stuff is returned to the user */
  62.     char    dta_attrib;
  63.     short    dta_time;
  64.     short    dta_date;
  65.     long    dta_size;
  66.     char    dta_name[TOS_NAMELEN+1];
  67. } DTABUF;
  68.  
  69. /* structure for opendir/readdir/closedir */
  70. typedef struct dirstruct {
  71.     fcookie fc;        /* cookie for this directory */
  72.     unsigned short    index;        /* index of the current entry */
  73.     unsigned short    flags;        /* flags (e.g. tos or not) */
  74. #define TOS_SEARCH    0x01
  75.     char    fsstuff[60];    /* anything else the file system wants */
  76.                             /* NOTE: this must be at least 45 bytes */
  77.     struct dirstruct *next;    /* linked together so we can close them
  78.                                on process termination */
  79. } DIR;
  80.  
  81. #ifndef _file_h
  82. /* structure for getxattr */
  83. typedef struct xattr {
  84.     unsigned short    mode;
  85. /* file types */
  86. #define S_IFMT    0170000        /* mask to select file type */
  87. #define S_IFCHR    0020000        /* BIOS special file */
  88. #define S_IFDIR    0040000        /* directory file */
  89. #define S_IFREG 0100000        /* regular file */
  90. #define S_IFIFO 0120000        /* FIFO */
  91. #define S_IMEM    0140000        /* memory region or process */
  92. #define S_IFLNK    0160000        /* symbolic link */
  93.  
  94. /* special bits: setuid, setgid, sticky bit */
  95. #define S_ISUID    04000
  96. #define S_ISGID 02000
  97. #define S_ISVTX    01000
  98.  
  99. /* file access modes for user, group, and other*/
  100. #define S_IRUSR    0400
  101. #define S_IWUSR 0200
  102. #define S_IXUSR 0100
  103. #define S_IRGRP 0040
  104. #define S_IWGRP    0020
  105. #define S_IXGRP    0010
  106. #define S_IROTH    0004
  107. #define S_IWOTH    0002
  108. #define S_IXOTH    0001
  109. #define DEFAULT_DIRMODE (0777)
  110. #define DEFAULT_MODE    (0666)
  111.     long    index;
  112.     unsigned short    dev;
  113.     unsigned short    reserved1;
  114.     unsigned short    nlink;
  115.     unsigned short    uid;
  116.     unsigned short    gid;
  117.     long    size;
  118.     long    blksize, nblocks;
  119.     unsigned short    mtime, mdate;
  120.     unsigned short    atime, adate;
  121.     unsigned short    ctime, cdate;
  122.     unsigned short    attr;
  123.     short    reserved2;
  124.     long    reserved3[2];
  125. } XATTR;
  126. #endif
  127.  
  128. typedef struct fileptr {
  129.     short    links;        /* number of copies of this descriptor */
  130.     unsigned short    flags;        /* file open mode and other file flags */
  131.     long    pos;        /* position in file */
  132.     long    devinfo;    /* device driver specific info */
  133.     fcookie    fc;        /* file system cookie for this file */
  134.     struct devdrv *dev; /* device driver that knows how to deal with this */
  135.     struct fileptr *next; /* link to next fileptr for this file */
  136. } FILEPTR;
  137.  
  138. #ifndef _file_h
  139. /* lock structure */
  140. struct flock {
  141.     short l_type;            /* type of lock */
  142. #define F_RDLCK        O_RDONLY
  143. #define F_WRLCK        O_WRONLY
  144. #define F_UNLCK        3
  145.     short l_whence;            /* SEEK_SET, SEEK_CUR, SEEK_END */
  146.     long l_start;            /* start of locked region */
  147.     long l_len;            /* length of locked region */
  148.     short l_pid;            /* pid of locking process
  149.                         (F_GETLK only) */
  150. };
  151. #endif
  152.  
  153. /* LOCK structure used by the kernel internally */
  154.  
  155. typedef struct ilock {
  156.     struct flock l;
  157.     struct ilock *next;
  158.     long  reserved[4];
  159. } LOCK;
  160.  
  161. typedef struct devdrv {
  162.     long (*open)    P_((FILEPTR *f));
  163.     long (*write)    P_((FILEPTR *f, char *buf, long bytes));
  164.     long (*read)    P_((FILEPTR *f, char *buf, long bytes));
  165.     long (*lseek)    P_((FILEPTR *f, long where, _wORD whence));
  166.     long (*ioctl)    P_((FILEPTR *f, _wORD mode, void *buf));
  167.     long (*datime)    P_((FILEPTR *f, _wORD *timeptr, _wORD rwflag));
  168.     long (*close)    P_((FILEPTR *f, _wORD pid));
  169.     long (*select)    P_((FILEPTR *f, long proc, _wORD mode));
  170.     void (*unselect) P_((FILEPTR *f, long proc, _wORD mode));
  171. /* extensions, check dev_descr.drvsize (size of DEVDRV struct) before calling:
  172.  * fast RAW tty byte io  */
  173.     long (*writeb)    P_((FILEPTR *f, const char *buf, long bytes));
  174.     long (*readb)    P_((FILEPTR *f, char *buf, long bytes));
  175. /* what about: scatter/gather io for DMA devices...
  176.  *    long ARGS_ON_STACK (*writev)    P_((FILEPTR *f, const struct iovec *iov, long cnt));
  177.  *    long ARGS_ON_STACK (*readv)    P_((FILEPTR *f, const struct iovec *iov, long cnt));
  178.  */
  179. } DEVDRV;
  180.  
  181. typedef struct filesys {
  182.     struct    filesys    *next;    /* link to next file system on chain */
  183.     long    fsflags;
  184. #define FS_KNOPARSE    0x01    /* kernel shouldn't do parsing */
  185. #define FS_CASESENSITIVE    0x02    /* file names are case sensitive */
  186. #define FS_NOXBIT    0x04    /* if a file can be read, it can be executed */
  187. #define    FS_LONGPATH    0x08    /* file system understands "size" argument to
  188.                                "getname" */
  189.  
  190.     long    (*root) P_((_wORD drv, fcookie *fc));
  191.     long    (*lookup) P_((fcookie *dir, char *name, fcookie *fc));
  192.     long    (*creat) P_((fcookie *dir, char *name, unsigned _wORD mode,
  193.                 _wORD attrib, fcookie *fc));
  194.     DEVDRV *(*getdev) P_((fcookie *fc, long *devspecial));
  195.     long    (*getxattr) P_((fcookie *fc, XATTR *xattr));
  196.     long    (*chattr) P_((fcookie *fc, _wORD attr));
  197.     long    (*chown) P_((fcookie *fc, _wORD uid, _wORD gid));
  198.     long    (*chmode) P_((fcookie *fc, unsigned _wORD mode));
  199.     long    (*mkdir) P_((fcookie *dir, char *name, unsigned _wORD mode));
  200.     long    (*rmdir) P_((fcookie *dir, char *name));
  201.     long    (*remove) P_((fcookie *dir, char *name));
  202.     long    (*getname) P_((fcookie *relto, fcookie *dir, char *pathname));
  203.     long    (*rename) P_((fcookie *olddir, char *oldname,
  204.                 fcookie *newdir, char *newname));
  205.     long    (*opendir) P_((DIR *dirh, _wORD tosflag));
  206.     long    (*readdir) P_((DIR *dirh, char *nm, _wORD nmlen, fcookie *fc));
  207.     long    (*rewinddir) P_((DIR *dirh));
  208.     long    (*closedir) P_((DIR *dirh));
  209.     long    (*pathconf) P_((fcookie *dir, _wORD which));
  210.     long    (*dfree) P_((fcookie *dir, long *buf));
  211.     long    (*writelabel) P_((fcookie *dir, char *name));
  212.     long    (*readlabel) P_((fcookie *dir, char *name, _wORD namelen));
  213.     long    (*symlink) P_((fcookie *dir, char *name, char *to));
  214.     long    (*readlink) P_((fcookie *dir, char *buf, _wORD len));
  215.     long    (*hardlink) P_((fcookie *fromdir, char *fromname,
  216.                 fcookie *todir, char *toname));
  217.     long    (*fscntl) P_((fcookie *dir, char *name, _wORD cmd, long arg));
  218.     long    (*dskchng) P_((_wORD drv));
  219.     long    (*release) P_((fcookie *));
  220.     long    (*dupcookie) P_((fcookie *new, fcookie *old));
  221. } FILESYS;
  222.  
  223. /*
  224.  * this is the structure passed to loaded file systems to tell them
  225.  * about the kernel
  226.  */
  227. /* structure for timeouts, the `void*'s are really `struct proc *'s */
  228. typedef struct timeout {
  229.     struct timeout    *next;
  230.     void    *proc;
  231.     long    when;
  232.     void    (*func) (void * any); /* function to call at timeout */
  233.     short    flags;
  234. } TIMEOUT;
  235.  
  236. typedef long (*_LongFunc)();
  237.  
  238. struct kerinfo {
  239.     short    maj_version;    /* kernel version number */
  240.     short    min_version;    /* minor kernel version number */
  241.     unsigned short default_mode;    /* default file access mode */
  242.     short    reserved1;    /* room for expansion */
  243.  
  244. /* OS functions */
  245.     _LongFunc *bios_tab;     /* pointer to the BIOS entry points */
  246.     _LongFunc *dos_tab;    /* pointer to the GEMDOS entry points */
  247.  
  248. /* media change vector */
  249.     void    (*drvchng) P_((short));
  250.  
  251. /* Debugging stuff */
  252.     void    (*trace) P_((char *, ...));
  253.     void    (*debug) P_((char *, ...));
  254.     void    (*alert) P_((char *, ...));
  255.     void    (*fatal) P_((char *, ...));
  256.  
  257. /* memory allocation functions */
  258.     void *    (*kmalloc) P_((long));
  259.     void    (*kfree) P_((void *));
  260.     void *    (*umalloc) P_((long));
  261.     void    (*ufree) P_((void *));
  262.  
  263. /* utility functions for string manipulation */
  264.     short    (*strnicmp) P_((char *, char *, _wORD));
  265.     short    (*stricmp) P_((char *, char *));
  266.     char *    (*strlwr) P_((char *));
  267.     char *    (*strupr) P_((char *));
  268.     short    (*sprintf) P_((char *, char *, ...));
  269.  
  270. /* utility functions for manipulating time */
  271.     void    (*millis_time) P_((unsigned long, _wORD *));
  272.     long    (*unixtim) P_((unsigned _wORD, unsigned _wORD));
  273.     long    (*dostim) P_((long));
  274.  
  275. /* utility functions for dealing with pauses */
  276.     void    (*nap) P_((unsigned short));
  277.     void    (*sleep) P_((_wORD que, long cond));
  278.     void    (*wake) P_((_wORD que, long cond));
  279.     void    (*wakeselect) P_((long param));
  280.  
  281. /* file system utility functions */
  282.     short    (*denyshare) P_((FILEPTR *, FILEPTR *));
  283.     LOCK *    (*denylock) P_((LOCK *, LOCK *));
  284.  
  285. /* functions for adding/cancelling timeouts */
  286.     TIMEOUT * (*addtimeout) P_((long, void (*)()));
  287.     void    (*canceltimeout) P_((TIMEOUT *));
  288.     TIMEOUT * (*addroottimeout) P_((long, void (*)(), short));
  289.     void    (*cancelroottimeout) P_((TIMEOUT *));
  290.  
  291. /* miscellaneous other things */
  292.     long    (*ikill) P_((short, short));
  293.     void    (*iwake) P_((short, long, short));
  294.  
  295. /* reserved for future use */
  296.     long    res2[3];
  297. };
  298.  
  299. #ifndef _file_h
  300. /* flags for open() modes */
  301. #define O_RWMODE      0x03    /* isolates file read/write mode */
  302. #    define O_RDONLY    0x00
  303. #    define O_WRONLY    0x01
  304. #    define O_RDWR    0x02
  305. #    define O_EXEC    0x03    /* execute file; used by kernel only */
  306.  
  307. #define O_APPEND    0x08    /* all writes go to end of file */
  308.  
  309. #define O_SHMODE    0x70    /* isolates file sharing mode */
  310. #    define O_COMPAT    0x00    /* compatibility mode */
  311. #    define O_DENYRW    0x10    /* deny both read and write access */
  312. #    define O_DENYW    0x20    /* deny write access to others */
  313. #    define O_DENYR    0x30    /* deny read access to others */
  314. #    define O_DENYNONE 0x40    /* don't deny any access to others */
  315.  
  316. #define O_NOINHERIT    0x80    /* children don't get this file descriptor */
  317.  
  318. #define O_NDELAY    0x100    /* don't block for i/o on this file */
  319. #define O_CREAT        0x200    /* create file if it doesn't exist */
  320. #define O_TRUNC        0x400    /* truncate file to 0 bytes if it does exist */
  321. #define O_EXCL        0x800    /* fail open if file exists */
  322.  
  323. #define O_USER        0x0fff    /* isolates user-settable flag bits */
  324.  
  325. #define O_GLOBAL    0x1000    /* for Fopen: opens a global file handle */
  326.  
  327. /* kernel mode bits -- the user can't set these! */
  328. #define O_TTY        0x2000    /* FILEPTR refers to a terminal */
  329. #define O_HEAD        0x4000    /* FILEPTR is the master side of a fifo */
  330. #define O_LOCK        0x8000    /* FILEPTR has had locking Fcntl's performed */
  331.  
  332.  
  333. /* GEMDOS file attributes */
  334. #endif
  335. /* macros to be applied to FILEPTRS to determine their type */
  336. #define is_terminal(f) (f->flags & O_TTY)
  337.  
  338. #ifndef _file_h
  339. /* lseek() origins */
  340. #define    SEEK_SET    0        /* from beginning of file */
  341. #define    SEEK_CUR    1        /* from current location */
  342. #define    SEEK_END    2        /* from end of file */
  343.  
  344. /* The requests for Dpathconf() */
  345. #define DP_IOPEN    0    /* internal limit on # of open files */
  346. #define DP_MAXLINKS    1    /* max number of hard links to a file */
  347. #define DP_PATHMAX    2    /* max path name length */
  348. #define DP_NAMEMAX    3    /* max length of an individual file name */
  349. #define DP_ATOMIC    4    /* # of bytes that can be written atomically */
  350. #define DP_TRUNC    5    /* file name truncation behavior */
  351. #    define    DP_NOTRUNC    0    /* long filenames give an error */
  352. #    define    DP_AUTOTRUNC    1    /* long filenames truncated */
  353. #    define    DP_DOSTRUNC    2    /* DOS truncation rules in effect */
  354. #define DP_CASE        6    /* file name case conversion behavior */
  355. #    define    DP_CASESENS    0    /* case sensitive */
  356. #    define    DP_CASECONV    1    /* case always converted */
  357. #    define    DP_CASEINSENS    2    /* case insensitive, preserved */
  358.  
  359. #define DP_MAXREQ    6    /* highest legal request */
  360.  
  361. /* Dpathconf and Sysconf return this when a value is not limited
  362.    (or is limited only by available memory) */
  363.  
  364. #define UNLIMITED    0x7fffffffL
  365.  
  366. #endif
  367.  
  368. /* various character constants and defines for TTY's */
  369. #define MiNTEOF 0x0000ff1a    /* 1a == ^Z */
  370.  
  371. /* defines for tty_read */
  372. #define RAW    0
  373. #define COOKED    0x1
  374. #define NOECHO    0
  375. #define ECHO    0x2
  376. #define ESCSEQ    0x04        /* cursor keys, etc. get escape sequences */
  377.  
  378. #ifndef _file_h
  379. /* constants for various Fcntl commands */
  380. /* constants for Fcntl calls */
  381. #define F_DUPFD        0        /* handled by kernel */
  382. #define F_GETFD        1        /* handled by kernel */
  383. #define F_SETFD        2        /* handled by kernel */
  384. #    define FD_CLOEXEC    1    /* close on exec flag */
  385.  
  386. #define F_GETFL        3        /* handled by kernel */
  387. #define F_SETFL        4        /* handled by kernel */
  388. #define F_GETLK        5
  389. #define F_SETLK        6
  390. #define F_SETLKW    7
  391.  
  392. #define FSTAT        (('F'<< 8) | 0)    /* handled by kernel */
  393. #define FIONREAD    (('F'<< 8) | 1)
  394. #define FIONWRITE    (('F'<< 8) | 2)
  395. #define TIOCGETP    (('T'<< 8) | 0)
  396. #define TIOCSETP    (('T'<< 8) | 1)
  397. #define TIOCSETN TIOCSETP
  398. #define TIOCGETC    (('T'<< 8) | 2)
  399. #define TIOCSETC    (('T'<< 8) | 3)
  400. #define TIOCGLTC    (('T'<< 8) | 4)
  401. #define TIOCSLTC    (('T'<< 8) | 5)
  402. #define TIOCGPGRP    (('T'<< 8) | 6)
  403. #define TIOCSPGRP    (('T'<< 8) | 7)
  404. #define TIOCFLUSH    (('T'<< 8) | 8)
  405. #define TIOCSTOP    (('T'<< 8) | 9)
  406. #define TIOCSTART    (('T'<< 8) | 10)
  407. #define TIOCGWINSZ    (('T'<< 8) | 11)
  408. #define TIOCSWINSZ    (('T'<< 8) | 12)
  409. #define TIOCGXKEY    (('T'<< 8) | 13)
  410. #define TIOCSXKEY    (('T'<< 8) | 14)
  411. #define TIOCIBAUD    (('T'<< 8) | 18)
  412. #define TIOCOBAUD    (('T'<< 8) | 19)    /* ??    */
  413. #define TIOCCBRK    (('T'<< 8) | 20)
  414. #define TIOCSBRK    (('T'<< 8) | 21)
  415.  
  416. #define TIOCGFLAGS (('T'<< 8) | 22)
  417. #define TIOCSFLAGS (('T'<< 8) | 23)
  418.  
  419.  
  420. #define TIOCOUTQ    (('T'<< 8) | 24)
  421. //#define TIOCSETP    (('T'<< 8) | 25)
  422. #define TIOCHPCL    (('T'<< 8) | 26)
  423. #define TIOCCAR        (('T'<< 8) | 27)
  424. #define TIOCNCAR    (('T'<< 8) | 28)
  425. #define TIOCWONLINE    (('T'<< 8) | 29)
  426. #define TIOCSFLAGSB    (('T'<< 8) | 30)
  427. #define TIOCGSTATE    (('T'<< 8) | 31)
  428. #define TIOCSSTATEB    (('T'<< 8) | 32)
  429. #define TIOCGVMIN    (('T'<< 8) | 33)
  430. #define TIOCSVMIN    (('T'<< 8) | 34)
  431.  
  432. /* cursor control Fcntls:
  433.  * NOTE THAT THESE MUST BE TOGETHER
  434.  */
  435. #define TCURSOFF    (('c'<< 8) | 0)
  436. #define TCURSON        (('c'<< 8) | 1)
  437. #define TCURSBLINK    (('c'<< 8) | 2)
  438. #define TCURSSTEADY    (('c'<< 8) | 3)
  439. #define TCURSSRATE    (('c'<< 8) | 4)
  440. #define TCURSGRATE    (('c'<< 8) | 5)
  441.  
  442. /* process stuff */
  443. #define PPROCADDR    (('P'<< 8) | 1)
  444. #define PBASEADDR    (('P'<< 8) | 2)
  445. #define PCTXTSIZE    (('P'<< 8) | 3)
  446. #define PSETFLAGS    (('P'<< 8) | 4)
  447. #define PGETFLAGS    (('P'<< 8) | 5)
  448. #define PTRACESFLAGS    (('P'<< 8) | 6)
  449. #define PTRACEGFLAGS    (('P'<< 8) | 7)
  450. #    define    P_ENABLE    (1 << 0)    /* enable tracing */
  451. #ifdef NOTYETDEFINED
  452. #    define    P_DOS        (1 << 1)    /* trace DOS calls - unimplemented */
  453. #    define    P_BIOS        (1 << 2)    /* trace BIOS calls - unimplemented */
  454. #    define    P_XBIOS        (1 << 3)    /* trace XBIOS calls - unimplemented */
  455. #endif
  456.  
  457. #define PTRACEGO    (('P'<< 8) | 8)    /* these 4 must be together */
  458. #define PTRACEFLOW    (('P'<< 8) | 9)
  459. #define PTRACESTEP    (('P'<< 8) | 10)
  460. #define PTRACE11    (('P'<< 8) | 11)
  461. #define PLOADINFO    (('P'<< 8) | 12)
  462. #define    PFSTAT        (('P'<< 8) | 13)
  463.  
  464. #define PPROCADDR    (('P'<< 8) | 1)
  465. #define PBASEADDR    (('P'<< 8) | 2)
  466. #define PCTXTSIZE    (('P'<< 8) | 3)
  467. #define PSETFLAGS    (('P'<< 8) | 4)
  468. #define PGETFLAGS    (('P'<< 8) | 5)
  469.  
  470. #define SHMGETBLK    (('M'<< 8) | 0)
  471. #define SHMSETBLK    (('M'<< 8) | 1)
  472.  
  473. /* terminal control constants (tty.sg_flags) */
  474. #define T_CRMOD        0x0001
  475. #define T_CBREAK    0x0002
  476. #define T_ECHO        0x0004
  477.  #define T_XTABS    0x0008  /* unimplemented*/
  478. #define T_RAW        0x0010
  479.  #define T_LCASE    0x0020  /* unimplemented */
  480.  
  481. #define T_NOFLSH    0x0040        /* don't flush buffer when signals
  482.                        are received */
  483. #define T_TOS        0x0080
  484. #define T_TOSTOP    0x0100
  485. #define T_XKEY        0x0200        /* Fread returns escape sequences for
  486.                        cursor keys, etc. */
  487. #define T_ECHOCTL    0x0400        /* echo ctl chars as ^x */
  488. /* 0x0800 still available */
  489.  
  490. #define T_TANDEM    0x1000
  491. #define T_RTSCTS    0x2000
  492. #define T_EVENP        0x4000        /* EVENP and ODDP are mutually exclusive */
  493. #define T_ODDP        0x8000
  494.  
  495. #define TF_FLAGS    0xF000
  496.  
  497. /* some flags for TIOC[GS]FLAGS */
  498. #define TF_CAR        0x800        /* nonlocal mode, require carrier */
  499. #define TF_NLOCAL    TF_CAR
  500.  
  501. #define TF_BRKINT    0x80        /* allow breaks interrupt (like ^C) */
  502.  
  503. #define TF_STOPBITS    0x0003
  504. #define TF_1STOP    0x0001
  505. #define TF_15STOP    0x0002
  506. #define    TF_2STOP    0x0003
  507.  
  508. #define TF_CHARBITS    0x000C
  509. #define TF_8BIT        0
  510. #define TF_7BIT        0x4
  511. #define TF_6BIT        0x8
  512. #define TF_5BIT        0xC
  513.  
  514. /* the following are terminal status flags (tty.state) */
  515. /* (the low byte of tty.state indicates a part of an escape sequence still
  516.  * hasn't been read by Fread, and is an index into that escape sequence)
  517.  */
  518. #define TS_ESC        0x00ff
  519. #define TS_BLIND    0x800        /* tty is `blind' i.e. has no carrier
  520.                        (cleared in local mode) */
  521. #define TS_HOLD        0x1000        /* hold (e.g. ^S/^Q) */
  522. #define TS_HPCL        0x4000        /* hang up on close */
  523. #define TS_COOKED    0x8000        /* interpret control chars */
  524.  
  525.  
  526. /* the following are terminal status flags (tty.state) */
  527. /* (the low byte of tty.state indicates a part of an escape sequence still
  528.  * hasn't been read by Fread, and is an index into that escape sequence)
  529.  */
  530. #define TS_ESC        0x00ff
  531. #define TS_HOLD        0x1000        /* hold (e.g. ^S/^Q) */
  532. #define TS_COOKED    0x8000        /* interpret control chars */
  533.  
  534. /* structures for terminals */
  535. struct tchars {
  536.     char t_intrc;
  537.     char t_quitc;
  538.     char t_startc;
  539.     char t_stopc;
  540.     char t_eofc;
  541.     char t_brkc;
  542. };
  543.  
  544. struct ltchars {
  545.     char t_suspc;
  546.     char t_dsuspc;
  547.     char t_rprntc;
  548.     char t_flushc;
  549.     char t_werasc;
  550.     char t_lnextc;
  551. };
  552.  
  553. struct sgttyb {
  554.     char sg_ispeed;
  555.     char sg_ospeed;
  556.     char sg_erase;
  557.     char sg_kill;
  558.     unsigned short sg_flags;
  559. };
  560.  
  561. struct winsize {
  562.     short    ws_row;
  563.     short    ws_col;
  564.     short    ws_xpixel;
  565.     short    ws_ypixel;
  566. };
  567.  
  568. struct xkey {
  569.     short    xk_num;
  570.     char    xk_def[8];
  571. };
  572. #endif
  573.  
  574. struct tty {
  575.     short        pgrp;        /* process group of terminal */
  576.     short        state;        /* terminal status, e.g. stopped */
  577.     short        use_cnt;    /* number of times terminal is open */
  578.     short        res1;        /* reserved for future expansion */
  579.     struct sgttyb     sg;
  580.     struct tchars     tc;
  581.     struct ltchars     ltc;
  582.     struct winsize    wsiz;
  583.     long        rsel;        /* selecting process for read */
  584.     long        wsel;        /* selecting process for write */
  585.     char        *xkey;        /* extended keyboard table */
  586.     long        rsrvd[3];    /* reserved for future expansion */
  587. };
  588.  
  589. /* defines and declarations for Dcntl operations */
  590. #ifndef _file_h
  591. #define DEV_INSTALL    0xde02
  592. #define DEV_NEWBIOS    0xde01
  593. #define DEV_NEWTTY    0xde00
  594. #endif
  595. struct dev_descr {
  596.     DEVDRV    *driver;
  597.     short    dinfo;
  598.     short    flags;
  599.     struct tty *tty;
  600.     long    reserved[4];
  601. };
  602.  
  603. #define FS_INSTALL    0xf001  /* let the kernel know about the file system */
  604. #define FS_MOUNT      0xf002  /* make a new directory for a file system */
  605. #define FS_UNMOUNT    0xf003  /* remove a directory for a file system */
  606. #define FS_UNINSTALL  0xf004  /* remove a file system from the list */
  607.  
  608.  
  609. struct fs_descr
  610. {
  611.     FILESYS *file_system;
  612.     short dev_no;    /* this is filled in by MiNT if arg == FS_MOUNT*/
  613.     long flags;
  614.     long reserved[4];
  615. };
  616.  
  617.  
  618. /* number of BIOS drives */
  619. #define NUM_DRIVES 32
  620.  
  621. #define BIOSDRV (NUM_DRIVES)
  622. #define PIPEDRV (NUM_DRIVES+1)
  623. #define PROCDRV (NUM_DRIVES+2)
  624. #define SHMDRV    (NUM_DRIVES+3)
  625.  
  626. #define UNI_NUM_DRVS (NUM_DRIVES+4)
  627. #define UNIDRV    ('U'-'A')
  628.  
  629. #define PSEUDODRVS ((1L<<UNIDRV))
  630.  
  631. /* various fields for the "rdev" device numbers */
  632. #define BIOS_DRIVE_RDEV     0x0000
  633. #define BIOS_RDEV    0x0100
  634. #define FAKE_RDEV    0x0200
  635. #define PIPE_RDEV    0x7e00
  636. #define UNK_RDEV    0x7f00
  637. #define PROC_RDEV_BASE    0xa000
  638.  
  639. #ifndef GENMAGIC
  640. /* external variables */
  641.  
  642. extern FILESYS *drives[NUM_DRIVES];
  643. extern struct tty default_tty;
  644. #define follow_links ((char *)-1L)
  645.  
  646. #endif
  647.  
  648. /* internal bios file structure */
  649.  
  650. #define    BNAME_MAX    13
  651.  
  652. struct bios_file {
  653.     char     name[BNAME_MAX+1];    /* device name */
  654.     DEVDRV *device;            /* device driver for device */
  655.     short    private;        /* extra info for device driver */
  656.     unsigned short    flags;        /* flags for device open */
  657.     struct tty *tty;        /* tty structure (if appropriate) */
  658.     struct bios_file *next;
  659.     short    lockpid;        /* owner of the lock */
  660.     XATTR    xattr;            /* guess what... */
  661.     long    drvsize;        /* size of DEVDRV struct */
  662. };
  663.  
  664.  
  665.  
  666. /* defines for TOS attribute bytes */
  667. #ifndef FA_RDONLY
  668. #define           FA_RDONLY           0x01
  669. #define           FA_HIDDEN           0x02
  670. #define           FA_SYSTEM           0x04
  671. #define           FA_LABEL               0x08
  672. #define           FA_DIR               0x10
  673. #define           FA_CHANGED           0x20
  674. #endif
  675.  
  676. #endif /* _filesys_h */
  677.